//
//  VC2Stepper.swift
//  ChapterAll
//
//  Created by Kevin on 2020/4/22.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class VC2Stepper: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let stepper = UIStepper()
        stepper.center = CGPoint(x: view.bounds.width / 2, y: view.bounds.height / 2)
        // 到最大值时，是否循环
        stepper.wraps = true
        // 长按，是否自动增加
        stepper.autorepeat = true
        // 长按时起作用
        stepper.isContinuous = true
        
        stepper.stepValue = 1
        stepper.minimumValue = 1
        stepper.maximumValue = 5
        
        view.addSubview(stepper)
    
        stepper.setDecrementImage(UIImage(named: "ic_action_anchor"), for: .normal)
        stepper.addTarget(self, action: #selector(clickStepper(ui:)), for: .valueChanged)
    }
    
    @objc func clickStepper(ui:UIStepper) -> Void {
        print("\(ui.value)")
    }
}
